 sbtl 'prodos machine language interface'
dispadr equ $1000 ;dispatcher load address
rwts equ $d000 ;disk driver entry 
 ifeq os-prodos
orig equ $d700
orig1 equ $de00
 fin
 ifeq os-ednet
orig equ $f800 ;start of buffers ** see rev note #en1 **
orig1 equ $d000 ;mli code starting address * #en1 *
 fin
globals equ $bf00  
inthandler equ $ff9b ; start of interrupt handler.
network equ $d400 ;applebus driver (main lc - bank 2)
pathbuf equ orig 
fcb equ orig+$100 ;file control block
vcb equ orig+$200 ;volume control block
bmbuf equ orig+$300 ;bit map buffer
gbuf equ orig+$500 ;general buffer
*
*
 ifeq os-ednet
*
*  load addresses in build.ednet basic program
*
mli.0 equ $2000 ;mli loader/relocater
ram.1 equ mli.0+$b00 ;$2b00 - installer for /ram
ram.0 equ ram.1+$100 ;$2c00 - /ram driver in aux mem
ram.2 equ ram.0+$200 ;$2e00 - /ram driver in main lc.
mli.2 equ ram.2+$100 ;$2f00 - mli
mli.1 equ mli.2+$2800 ;$5700 - global page
tclock.0 equ mli.1+$100 ;$5800 - tclock driver
mli.3 equ tclock.0+$100 ;$5900 - interrupts
xrw.0 equ mli.3+$100 ;$5a00 - disk core routines
sel.0 equ xrw.0+$700 ;$6100 - dispatcher
 fin
*
 ifeq os-prodos
*
*  load addresses in build.prodos basic program
*
mli.0 equ $2000 ;mli loader/relocater
ram.1 equ mli.0+$b00 ;$2b00 - installer for /ram
ram.0 equ ram.1+$100 ;$2b00 - /ram driver in aux mem
ram.2 equ ram.0+$200 ;$2d00 - /ram driver in main lc.
mli.2 equ ram.2+$100 ;$2e00 - mli
mli.1 equ mli.2+$2100 ;$4f00 - global page
tclock.0 equ mli.1+$100 ;$5000 - tclock driver
mli.3 equ tclock.0+$9b ;$509b - interrupts
xrw.0 equ tclock.0+$100 ;$5100 - disk core routines
sel.0 equ xrw.0+$700 ;$5800 - dispatcher
*
********* see rev note #50 *********
*
cclock.0 equ sel.0+$300 ; $5b00 - cortland clock driver
************************************
* -------------------- see rev note 20 and 50 -----------------
*bus.0 equ sel.0+$300 ;$5b00 - applebus driver
* -------------------------------------------------------
 fin
*
tclk.in equ pathbuf+$42 ;clock driver execution address
*
* standard error codes 
*
badscnum equ $01 ;bad system call #
badscpcnt equ $04 ;bad call parameter count
intblful equ $25 ;interupt table full.
xioerr equ $27
xnodrv equ $28 ;no device connected.
xnowrite equ $2b ;disk/media is hardware write protected
dswtched equ $2e ;wrong volume is mounted on active device.
devoffline equ $2f ; device off line, or no disk in drive.
badpath equ $40 ;invalid pathname syntax
fcbfull equ $42 ;file control block full
badrefnum equ $43 ;invalid refnum
vnferr equ $45 ;volume not found
pathnotfnd equ $44 ;pathname not found
fnferr equ $46 ;file not found
duperr equ $47 ;duplicate file name error
ovrerr equ $48 ;not enough disk space for preallocation
dirfull equ $49 ;directory full error
cpterr equ $4a ;file incompatible sos version
typerr equ $4b ;not currently supported storage type
eoferr equ $4c ;position attempted beyond end of file
posnerr equ $4d ;illegal position (l.t. 0 or g.t. $ffffff)
accserr equ $4e ;file access r/w request conflicts with attributes.
filbusy equ $50 ;either write was requested or write access already allocated.
direrr equ $51 ; directory entry count inconsistent with actual entries
notsos equ $52 ;not an xdos diskette
badlstcnt equ $53 ;invalid value in list parameter
vcbfull equ $55 ;too many devices...
badbuf equ $56 
dupvol equ $57 ;duplicate volume can't be logged in.
bitmapadr equ $5a ; bit map disk address impossible
*
* fatal errors
*
badirq equ $01 ;unclaimed interrupt
vcberr equ $0a ;volume control block not usable
fcberr equ $0b
alcerr equ $0c ;allocation blocks invalid
 page
*
* constants
*
seedtyp equ 1
saptyp equ 2
tretyp equ 3
dirtyp equ $d
hedtyp equ $e
rdcmd equ $1 
wrtcmd equ $2 
statcmd equ $00 ;request status, no error=ready 
pretime equ $20 ;command needs current date/time stamp
preref equ $40 ;command requires fcb address and verification
prepath equ $80 ;command has pathname to preprocess
*
* volume status constants (bits)
*
*
* file status constants
*
datalc equ $1 ;data block not allocated.
idxalc equ $2 ;index not allocated
topalc equ $4 ;top index not allocated
stpmod equ $8 ;storage type modified
usemod equ $10 ;file usage modified
eofmod equ $20 ;end of file modified
datmod equ $40 ;data block modified
idxmod equ $80 ;index block modified
fcbmod equ $80 ; has fcb/directory been modified? (flush)
*
* file attributes constants
*
readen equ $1 ;read enabled
writen equ $2 ;write enabled
renamen equ $40 ;rename ok when on.
dstroyen equ $80 ;destroy ok when on.
 page 
* header index constants
*
hnlen equ $0 ;header name length (offset into header)
*hname equ $1 ; header name
hpenab equ $10 ;password enable byte
hpass equ $11 ;encoded password
hcrdt equ $18 ;header creation date
* hcrtm equ $1a ;header creation time 
hver equ $1c ;sos version that created directory
hcmp equ $1d ;backward compatible with sos version
hattr equ $1e ;header attributes- protect etc.
* hentln equ $1f ;length of each entry
* hment equ $20 ;maximum number of entries/block
hcent equ $21 ;current number of files in directory
hrblk equ $23 ;owner's directory address
hrent equ $25 ;owner's directory entry number 
hreln equ $26 ;owner's directory entry length 
vbmap equ hrblk
vtblk equ hrent ;(used for root directory only) 
*
* volume control block index constants
*
vcbsize equ $20 ;current vcb is 32 bytes per entry (ver 0)
vcbnml equ 0 ;volume name length byte
vcbnam equ 1 ;volume name
vcbdev equ $10 ;volume's device
vcbstat equ $11 ;volume status. (80=files open. 40=disk switched.) 
vcbtblk equ $12 ;total blocks on this volume
vcbtfre equ $14 ;number of unused blocks
vcbroot equ $16 ;root directory (disk) address
*vcbmorg equ $18 ; map organization (not supported by v 0)
*vcbmbuf equ $19 ; bit map buf num
vcbdmap equ $1a ;first (disk) address of bitmap(s)
vcbcmap equ $1c ;relative address of bit map with space (add to vcbdmap)
*vcbmnum equ $1d ; relative bit map currently in memory
vcbopnc equ $1e ;current number of open files.
*vcb addr $1f reserved
*
* file control block index constants
*
fcbrefn equ 0 ;file reference number (position sensitive)
fcbdevn equ 1 ;device (number) on which file resides
*fcbhead equ 2 ; block address of file's directory header
*fcbdirb equ 4 ; block address of file's directory
fcbentn equ 6 ;entry number within directory block
fcbstyp equ 7 ;storage type - seed, sapling, tree, etc.
fcbstat equ 8 ;status - index/data/eof/usage/type modified.
fcbattr equ 9 ;attributes - read/write enable, newline enable.
fcbnewl equ $a ;new line terminator (all 8 bits significant).
fcbfbuf equ $b ;buffer number
fcbfrst equ $c ;first block of file
fcbidxb equ $e ;block address of index (0 if no index)
fcbdatb equ $10 ;block address of data
fcbmark equ $12 ;current file marker.
fcbeof equ $15 ;logical end of file.
fcbuse equ $18 ;actual number of blocks allocated to this file.
*fcb addr $1a reserved
fcblevl equ $1b ; level at which this file was opened
fcbdirty equ $1c ; fcb marked as modified
fcbnlmsk equ $1f
 page
*
* zero page stuff
*
par equ $40 
device equ par+2 
dhpcmd equ device 
unitnum equ device+1
dbufpl equ device+2
dbufph equ dbufpl+1
bloknml equ device+4 
bloknmh equ bloknml+1
*
intcmd equ dhpcmd
*
ztemps equ par+8 
tpath equ ztemps
drbufpl equ ztemps
drbufph equ drbufpl+1
tindx equ ztemps
datptr equ ztemps+2
posptr equ ztemps+4
usrbuf equ ztemps+6
*
* xdos parameters: 
*
c.pcnt equ $0 ; (count)
c.devnum equ $1 ; (value)
c.refnum equ $1 ; (value)
c.intnum equ $1 ; (value)
c.path equ $1 ;&2 (pointer) 
c.isnewl equ $2 ; (mask)
c.datbuf equ $2 ;&3 (value)
c.bufadr equ $2 ;&3 (address)
c.intadr equ $2 ;&3 (address)
c.mark equ $2 ;->4 (value)
c.eof equ $2 ;->4 (value)
c.attr equ $3 ; (flags) 
c.newl equ $3 ; (character)
c.bufptr equ $3 ;&4 (pointer)
c.nwpath equ $3 ;&4 (pointer)
c.filid equ $4 ; (value) 
c.reqcnt equ $4 ;&5 (value)
c.blknum equ $4 ;&5 (address)
c.outref equ $5
c.auxid equ $5 ;&6 (value) 
c.trnscnt equ $6 ;&7 (value)
c.fkind equ $7 ; (value) 
c.date equ $8 ;&9 (value) 
c.outblk equ $8 ;&9 (count)
c.time equ $a ;&b (value) 
c.moddate equ $a ;&b (value)
c.modtime equ $c ;&d (value)
c.credate equ $e ;&f (value)
c.cretime equ $10 ;&11 (value)
*
altram equ $c083
irqvect equ $fffe ;location of irq vector
romirq equ $fa41 ;monitor rom irq entry
m.break equ $fa59 ;monitor break vector
m.reset equ $ff59 ;monitor reset entry
m.and equ m.reset ;& vector
m.ctl.y equ m.reset ;control y vector
m.nmi equ m.reset ;nmi vector
*
rtbl equ $10
src equ $12
dst equ $14
cnt equ $16
cde equ $18
ecde equ $1a
look equ $0a ;must go at $000a!!
apple equ $0c 
unit equ $43
home equ $fc58
gopro equ $bf00 
lodintrp equ $800
pbuf equ $280
reset equ $3f2
name equ pbuf
prefix equ $c6
onlyne equ $c5 ;mli online call # 
iopen equ $c8
igeof equ $d1
iread equ $ca
iclos equ $cc
getfileinfo equ $c4 ; prodos get file info call number.
idbrd equ $80
*
* soft switches
*
ramin equ $c08b
ramin2 equ $c083
romin equ $c082 ;swap rom in, write protect ram
romin1 equ $c081 ;swap rom in w/o w-prot ram
slot3rom equ $c00b ;write location to switch in slot 3 rom
read3rom equ $c017 ; bit 7 =1 if slot space 3 enabled
int3rom equ $c00a ;write location to switch in internal 3 rom
